<?php
// +---------------------------------------------------------------------------+
// | This file is part of the KnowledgebasePublisher package                   |
// | KnowledgebasePublisher - web based knowledgebase publisher tool           |
// |                                                                           |
// | Author:  Evgeny Leontev <eleontev@gmail.com>                              |
// | Copyright (c) 2005 Evgeny Leontev                                         |
// |                                                                           |
// | For the full copyright and license information, please view the LICENSE   |
// | file that was distributed with this source code.                          |
// +---------------------------------------------------------------------------+

class KBClientView_print extends KBClientView_common
{

	function execute(&$manager) {
		
		if($this->msg_id == 'glossary') {
			return $this->getGloassary($manager);
		} else {
			return $this->getArticle($manager);
		}
	}
	
	
	function getArticle(&$manager) {
		
		$row = &$manager->getEntryById($this->entry_id, $this->category_id);
		$row = &$this->stripVars($row);
		if(empty($row)) { return; }
		
		$tpl = &new tplTemplatez($this->template_dir . 'article_print.html');
	
		$tpl->tplAssign('formated_date', $this->getFormatedDate($row['ts_updated']));	
		$tpl->tplAssign('meta_charset', $this->conf['lang']['meta_charset']);
		$tpl->tplAssign($this->css);
		
		$tpl->tplParse(array_merge($row, $this->msg));
		return $tpl->tplPrint(1);	
	}
	
	
	function getGloassary(&$manager) {
				
		$tpl = &new tplTemplatez($this->template_dir . 'glossary_print.html');
		
		foreach($manager->getGlossaryDefinitions() as $k => $v) {
			$v['phrase'] = $k;
			$tpl->tplParse($v, 'row');
		}
		
		$tpl->tplAssign('title',  $this->msg['glossary_msg']);
		$tpl->tplAssign('meta_charset', $this->conf['lang']['meta_charset']);	
		$tpl->tplAssign($this->css);
		
		$tpl->tplParse($this->msg);
		return $tpl->tplPrint(1);
	}
}
?>